package domain.dao;

import org.hibernate.HibernateException;
import org.hibernate.Query;

import domain.User;


/**
 * last change:  $Date$
 * by:           $Author$
 * revision:     $Revision$
 *
 */
public class UserDao extends AbstractDao {
  
  public UserDao() {
    super();
  }
  
  private final static String HQL_LOAD_USER = "from User where login = :login and password = :password";
  
  public User loadUser(String login, String password) {
    try {
      begin();
      Query query = getSession().createQuery(HQL_LOAD_USER);
      query.setString("login", login);
      query.setString("password", password);
      User user = (User)query.uniqueResult();
      commit();
      return user;
    } catch (HibernateException e) {
      rollback();
    }
    return null;
  }
  
}
